package com.hnucm.c202001020214;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.widget.Button;

import com.gyf.immersionbar.ImmersionBar;
import com.hnucm.c202001020214.object.Goods;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

public class Search_results extends BaseActivity {

    public List<Goods> goodsList = new ArrayList<>();
    RecyclerView recyclerView;
    Button buy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_results);
        ImmersionBar.with(this)
                // .statusBarColor(R.color.touming)
                .init();

        EventBus.getDefault().register(this);  //注册eventbus,
        recyclerView =findViewById(R.id.recyclerview);
        buy = findViewById(R.id.buy);

        LinearLayoutManager layoutManager = new LinearLayoutManager(Search_results.this);
        recyclerView.setLayoutManager(layoutManager);


    }
    @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)//指定线程
    public void messge(List<Goods.ItemsDTO.ItemDTO> e){
//        Log.i("qw7",e.get(0).getPrice());
        GoodsAdapter goodsAdapter = new GoodsAdapter(e);
        recyclerView.setAdapter(goodsAdapter);

    }
}